package org.jeecg.modules.generator.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.generator.entity.SysGenerateModuleConfig;
import org.jeecg.modules.generator.mapper.SysGenerateModuleConfigMapper;
import org.jeecg.modules.generator.service.SysGenerateModuleConfigService;
import org.jeecg.modules.generator.vo.SysGenerateModuleConfigVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang3.StringUtils;


/**
* @Description 生成模块路劲配置服务
* @Author yangfeng
* @Date 2021-06-30 10:58:26
*/
@Service
@Transactional
public class SysModuleConfigServiceImpl extends ServiceImpl<SysGenerateModuleConfigMapper, SysGenerateModuleConfig> implements SysGenerateModuleConfigService {


        /**
        * 根据查询条件导出生成模块路劲配置列表
        * @param sysGenerateModuleConfigVo
        * @return
        */
        public List<SysGenerateModuleConfig> exportEntityList(SysGenerateModuleConfigVo sysGenerateModuleConfigVo){

            QueryWrapper  queryWrapper = new QueryWrapper();
            if(sysGenerateModuleConfigVo.getIdList() !=null && sysGenerateModuleConfigVo.getIdList().size()>0){
                queryWrapper.in("ID",sysGenerateModuleConfigVo.getIdList());
            }else{
                if(StringUtils.isNotEmpty(sysGenerateModuleConfigVo.getProjectName())){
                    queryWrapper.like("PROJECT_NAME",sysGenerateModuleConfigVo.getProjectName());
                }
                if(StringUtils.isNotEmpty(sysGenerateModuleConfigVo.getDataSourceId())){
                    queryWrapper.like("DATA_SOURCE_ID",sysGenerateModuleConfigVo.getDataSourceId());
                }
            }
            List<SysGenerateModuleConfig> systemModuleConfigList = this.list(queryWrapper);
            return systemModuleConfigList;
        }

        /**
        * 保存excel导入的数据
        * @param systemModuleConfigList
        */
        public void importEntityList(List<SysGenerateModuleConfig> systemModuleConfigList){
            this.saveBatch(systemModuleConfigList);
        }
}
